//
//  WCShijianTableViewCell.m
//  XRSquare
//
//  Created by 穆相臣 on 2018/8/21.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "WCShijianTableViewCell.h"
@interface WCShijianTableViewCell ()
{
    UILabel * titleLabel;
    UILabel * timeLabel;
    UILabel * stateLabel;
    UIImageView * avatarImage;
    UILabel * nameLabel;
    UILabel * typeLabel;
}
@end

@implementation WCShijianTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:titleLabel];
    
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, ScreenWidth, 15)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:timeLabel];
        
        stateLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, ScreenWidth - 20, 15)];
        stateLabel.font = [UIFont systemFontOfSize:12];
        stateLabel.textColor = [UIColor colorFromHexCode:@"b3b3b3"];
        stateLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:timeLabel];
        
        avatarImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 60, 30, 30)];
        avatarImage.contentMode = UIViewContentModeScaleAspectFill;
        avatarImage.clipsToBounds = YES;
        [self addSubview:avatarImage];
        
        nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 60, ScreenWidth, 30)];
        nameLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:nameLabel];
        
        typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 20)];
        typeLabel.font = [UIFont systemFontOfSize:12];
        typeLabel.backgroundColor = themeColor;
        typeLabel.textColor = [UIColor whiteColor];
        typeLabel.layer.cornerRadius = 10;
        typeLabel.clipsToBounds = YES;
        typeLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:typeLabel];
        typeLabel.center = CGPointMake(ScreenWidth - 35, 75);
        
        UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 99, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
    }
    return self;
}

+(CGFloat)height
{
    return 100;
}

-(void)loadData:(NSDictionary *)data
{
    titleLabel.text = [data objectForKey:@"TaskTitle"];
    timeLabel.text = [NSString stringWithFormat:@"%@ - %@",[data objectForKey:@"TaskBeginTime"],[data objectForKey:@"TaskEndTime"]];
    stateLabel.text = [data objectForKey:@"StatusText"];
    [avatarImage sd_setImageWithURL:[NSURL URLWithString:[data objectForKey:@"TaskPublisherHeadPic"]]];
    nameLabel.text = [data objectForKey:@"TaskPublisherNickName"];
    typeLabel.text = [data objectForKey:@"TaskPublisherType"];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
